//
//  DetailFourSecond.m
//  HandWork
//
//  Created by 王阳阳 on 16/1/29.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DetailFourSecond.h"
#import "AppDelegate.h"
@implementation DetailFourSecond
- (void)dealloc
{
    [_titlelabel release];
    [_comtentlabel release];
    [_bgimg release];
    [_touxiang release];
    [_name release];
    [_other release];
    [super dealloc];
}

#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creat];
    }
    return self;
}
- (void)creat
{
    
    
    
    //背景图片
    self.bgimg = [[UIImageView alloc]init];
    [self.contentView addSubview:self.bgimg];
    [_bgimg release];
    UIBlurEffect *b = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    //高斯模糊
    UIVisualEffectView *bV = [[UIVisualEffectView alloc] initWithEffect:b];
    bV.frame = self.contentView.frame;
    [_bgimg addSubview:bV];
    [bV release];

    //标题
    self.titlelabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.titlelabel];
    [_titlelabel release];
    //内容
    self.comtentlabel = [[UILabel alloc]init];
    [self.contentView addSubview:self.comtentlabel];
    [_comtentlabel release];
    //头像
    self.touxiang = [[UIImageView alloc]init];
    [self.contentView addSubview:self.touxiang];
    [_touxiang release];
  
    
    //名字
    self.name = [[UILabel alloc]init];
    [self.contentView addSubview:self.name];
    [_name release];
    //其他评论 收藏 赞 人气
    self.other = [[UILabel alloc]init];
    [self.contentView addSubview:self.other];
    [_other release];
    
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    //背景图片
    self.bgimg.frame = [UIScreen mainScreen].bounds;
    
 
    //标题
    self.titlelabel.frame = CGRectMake(0, 50, [UIScreen mainScreen].bounds.size.width, 60);
    self.titlelabel.font = [UIFont systemFontOfSize:24];//字体大小
    self.titlelabel.textColor = [UIColor whiteColor];//字体颜色
    self.titlelabel.textAlignment = NSTextAlignmentCenter;//居中
    self.titlelabel.numberOfLines = 0;//不限行数
    //内容
    self.comtentlabel.frame = CGRectMake(10, self.titlelabel.frame.size.height + self.titlelabel.frame.origin.y, [UIScreen mainScreen].bounds.size.width - 20, 150);
    self.comtentlabel.numberOfLines = 0;//不限制行数
    self.comtentlabel.textColor = [UIColor whiteColor];//字体颜色
    //头像
    
    self.touxiang.frame = CGRectMake([UIScreen mainScreen].bounds.size.width / 2 - 30, 220, [UIScreen mainScreen].bounds.size.width / 5, [UIScreen mainScreen].bounds.size.width / 5);
    self.touxiang.layer.cornerRadius = [UIScreen mainScreen].bounds.size.width / 5 / 2;//圆角
    self.touxiang.clipsToBounds = YES;

    
    //用户交互
    self.touxiang.userInteractionEnabled = YES;
    //手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(face)];
    tap.numberOfTapsRequired = 1;
    [self.touxiang addGestureRecognizer:tap];
    //名字
    self.name.frame = CGRectMake(30, self.touxiang.frame.size.height + self.touxiang.frame.origin.y, [UIScreen mainScreen].bounds.size.width -60, 30);
    self.name.textColor = [UIColor whiteColor];//字体颜色
    self.name.textAlignment = NSTextAlignmentCenter;//居中
    //其他
    
    self.other.frame = CGRectMake(30, self.name.frame.size.height + self.name.frame.origin.y + 30, [UIScreen mainScreen].bounds.size.width - 60, 30);
    self.other.textColor = [UIColor whiteColor];//字体颜色
    self.other.font = [UIFont systemFontOfSize:14];//字体大小
    self.other.textAlignment = NSTextAlignmentCenter;//居中
    
}
- (void)face
{
//    AppDelegate *app = [[UIApplication sharedApplication]delegate];
//    UserViewController *user = [[UserViewController alloc]init];
//
//    [app.thirduina pushViewController:user animated:YES];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
